package com.wxxymakers.cklabrecruit.controller;

import com.wxxymakers.cklabrecruit.service.SysInfoService;
import com.wxxymakers.cklabrecruit.utils.RestResponse;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @AUTHOR soft
 * @DATE 2018/11/29 22:40
 * @DESCRIBE
 */
@RestController
@RequiresRoles({"admin"})
@RequestMapping("/sys")
public class SysInfoController {

    private final SysInfoService sysInfoService;

    @Autowired
    public SysInfoController(SysInfoService sysInfoService) {
        this.sysInfoService = sysInfoService;
    }

    @PostMapping("/reg/{can}")
    public RestResponse reg(@PathVariable Integer can) {
        if (sysInfoService.switchReg(can == 1)) {
            return RestResponse.ok();
        }
        return RestResponse.fail();
    }
}
